/*
 * @Author: your name
 * @Date: 2021-04-28 09:59:11
 * @LastEditTime: 2021-07-09 12:48:17
 * @LastEditors: Please set LastEditors
 * @Description: In User Settings Edit
 * @FilePath: \umi\src\services\renewal.ts
 */
import request from '@/utils/request';
import { post, get } from '@/utils/http';
import type {
  IRenewalGoodsReqest,
  IRenewalGoodsForModalReqest,
  IRenewalImportReqest,
  IRenewalFeaturedReqest,
  IRenewalProductInfoReqest,
  IRenewalpickUpReqest,
  IRenewalRecycleReqest,
  IReplaceProductRequest,
  IReplaceSMSRequest,
  IUpdateConfigRequest,
  IsmsReset,
} from '@/pages/renewalPanel/data.d';

export interface ICommonResponse<T> {
  code: number;
  data?: T;
  msg?: string | null;
  success: boolean;
  exception?: string;
}

// 分页查询产品管理列表(最外面的大展示)
export async function getRenewalList(params: IRenewalGoodsReqest) {
  // return post(`/api/renewal/product/pageList`, { data: params });
  return post({
    url: `/api/renewaling/renewal/product/pageList`,
    data: params,
  });
}

// 分页查询运营层产品列表 (添加产品的)
export async function getRenewalLisForModal(params: IRenewalGoodsForModalReqest) {
  return get({ url: `/api/renewaling/renewal/product/operation/pageList`, data: params });
}
// 导入产品
export async function importProduct(params: IRenewalImportReqest) {
  return post({ url: `/api/renewaling/renewal/product/import`, data: params });
}
// 目前推荐设置
export async function featuredSetting(params: IRenewalFeaturedReqest) {
  return post({ url: `/api/renewaling/renewal/product/featured`, data: params });
}
// 获取产品详情信息
export async function renewalProductDetail(params: IRenewalProductInfoReqest) {
  return get({ url: `/api/renewaling/renewal/product/${params.id}`, data: {} });
}
// 回收站产品拾回
export async function backUpRenewal(params: IRenewalpickUpReqest) {
  return post({ url: `/api/renewaling/renewal/product/pickUp`, data: params });
}

// 获取所有默认短信模板信息
export async function smsTemplates() {
  return get({ url: `/api/renewaling/renewal/product/smsTemplates`, data: {} });
}

// 移入回收站
export async function recycleRenewal(params: IRenewalRecycleReqest) {
  return post({ url: `/api/renewaling/renewal/product/recycle`, data: params });
}

export async function getFakeCaptcha(mobile: string) {
  return request(`/api/renewaling/login/captcha?mobile=${mobile}`);
}

export async function updateReplace(params: IReplaceProductRequest) {
  return post({ url: `/api/renewaling/renewal/product/updateReplace`, data: params });
}

// 修改产品短信配置
export async function updateSms(params: IReplaceSMSRequest) {
  return post({ url: `/api/renewaling/renewal/product/updateSms`, data: params });
}

// /renewal/product/updateConfig更新产品配置（设置通知、替代、推荐）
export async function updateConfig(params: IUpdateConfigRequest) {
  return post({ url: `/api/renewaling/renewal/product/updateConfig`, data: params });
}

// /renewal/product/resetSms重置产品短信配置
export async function resetSms(params: IsmsReset) {
  return get({ url: `/api/renewaling/renewal/product/resetSms`, data: params });
}
